package _04TestFactory01_02_03;

import java.math.BigDecimal;

public  class Operation implements OperationFactory{
    private String str1;
    private String str2;
    private String oper;

    public Operation(String str1,String oper,String str2){
        this.str1=str1;
        this.str2=str2;
        this.oper=oper;
    }
    public String getStr1() {
        return str1;
    }

    public void setStr1(String str1) {
        this.str1 = str1;
    }

    public String getStr2() {
        return str2;
    }

    public void setStr2(String str2) {
        this.str2 = str2;
    }

    public String getOper() {
        return oper;
    }

    public void setOper(String oper) {
        this.oper = oper;
    }

    public BigDecimal getResult() {
        if("+".equals(oper)){
            return BigDecimalUtil.add(this.str1,this.str2);
        }else if ("-".equals(oper)){
            return BigDecimalUtil.sub(this.str1,this,str2);
        }else if ("*".equals(oper)){
            return BigDecimalUtil.mul(this.str1,this,str2);
        }else if ("/".equals(oper)){
            return BigDecimalUtil.div(this.str1,this,str2);
        }
        return null;
    }
}
